from langchain_community.chat_models import ChatTongyi
from langchain_core.prompts.prompt import PromptTemplate
import os

os.environ["DASHSCOPE_API_KEY"] = "sk-9d8f1914800e497f8717144e860f99bc"
llm = ChatTongyi()

template = """
You are an expert data scientist with an expertise in building deep learning models.
Explain the concept of {concept} in a couple of lines
"""

"""
input_variables：输入的参数变量
template: 模板字符串
"""
prompt_template = PromptTemplate(
    input_variables=["concept"],
    template=template,
)
prompt = prompt_template.format(concept="deep learning")
result = llm.invoke(prompt)
print(result)

promptValue = prompt_template.invoke({"concept": "deep learning"})
prompt2 = promptValue.text
result2 = llm.invoke(prompt2)
print(result2)